package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 根据条件拿购物车的所有数据
     *
     * @param shoppingCart
     * @return {@link List}<{@link ShoppingCart}>
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 根据id修改数量
     *
     * @param shoppingCart1
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart shoppingCart1);

    /**
     * 添加
     *
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     *
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);


    /**
     * 根据disId和flavor删除单个商品
     *
     * @param shoppingCart
     */
    @Delete("delete from shopping_cart where dish_id = #{dishId} and dish_flavor = #{dishFlavor}")
    void deleteByDishIdAndFlavor(ShoppingCart shoppingCart);

    /**
     * 根据setmealId删除单个商品
     *
     * @param shoppingCart
     */
    @Delete("delete from shopping_cart where setmeal_id = #{setmealId}")
    void deleteBySetmealId(ShoppingCart shoppingCart);

    /**
     * 根据dishId删除单个商品
     *
     * @param shoppingCart
     */
    @Delete("delete from shopping_cart where dish_id = #{dishId}")
    void deleteByDishId(ShoppingCart shoppingCart);

    /**
     * 删除
     *
     * @param shoppingCart
     */
    void delete(ShoppingCart shoppingCart);


    /**
     * 再来一单
     *
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
